<template>
  <div>
    <p>试卷上传</p>
 <label >选择学期</label>
    <el-select v-model="type" placeholder="请选择">
      <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value"></el-option>
    </el-select>

    <label class="left">选择考试类型</label>
    <el-select v-model="term" placeholder="请选择">
      <el-option v-for="item in terms" :key="item.value" :label="item.label" :value="item.value"></el-option>
    </el-select>
  
<label class="left">选择完成时间</label>
        <el-time-select
  v-model="value"
  :picker-options="{
    start: '08:30',
    step: '00:15',
    end: '18:30'
  }"
  placeholder="选择时间">
</el-time-select>
<span class="left">
 <el-button type="primary" round @click="submit"  >上传试卷</el-button>
</span>
  </div>
</template>
<script>
export default { 
   data() {
      return {
        value: '',
         types:[
            {
          value: "第一次月考",
          label: "第一次月考"
        },
          {
          value: "第二次月考",
          label: "第二次月考"
        },
          {
          value: "第三次月考",
          label: "第三次月考"
        },
          {
          value: "期中考试",
          label: "期中考试"
        },
          {
          value: "第四次月考",
          label: "第四次月考"
        },
          {
          value: "第五次月考",
          label: "第五次月考"
        },
          {
          value: "第六次月考",
          label: "第六次月考"
        },
        {
          value: "期末考试",
          label: "期末考试"
        }
         ],
         type: "",
         terms: [
        {
          value: "高一上学期",
          label: "高一上学期"
        },
        {
          value: "高一下学期",
          label: "高一下学期"
        },
        {
          value: "高二上学期",
          label: "高二上学期"
        },  
        {
          value: "高二下学期",
          label: "高二下学期"
        },
        {
          value: "高三上学期",
          label: "高三上学期"
        },
        {
          value: "高三下学期",
          label: "高三下学期"
        }
      ],
     term : ""
      };
    },
  methods: {
      submit() {
 

     this.$msgbox({
        title: "确认提示",
        message:"是否为班级考试？"
        ,
        showCancelButton: true,
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        beforeClose: (action, instance, done) => {
          if (action === "confirm") {
            instance.confirmButtonLoading = true;
            instance.confirmButtonText = "执行中...";
           
           this.$axios
            .get(
          "http://localhost:8080/teacher/paper_upload",
        
         {params:{
           type: this.type,
           term: this.term,
           endtime: this.value,
           userid:this.$store.state.userid
           }}).then(resp=>{
                    
                    this.message=resp.data
                });


            setTimeout(() => {
              done();
              setTimeout(() => {
                instance.confirmButtonLoading = false;
              }, 300);
            }, 1000);        
          } else {
            done();
          }
        }
      })
      .then(action => {
       if(this.message==200){
          this.$message({
         message:"上传试卷成功",
        type: "success"
        });
       }
       else{
          this.$message({
         message:"上传试卷失败，请重新上传！",
       
        });
       }
      });


      },
  }
  }
</script>
<style scoped>
.left{
  padding-left: 50px;
}

</style>
